﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BiliBiliCSharpStudy.old {
    /**
     * 获取基本类型的字节数
     */
    class SizeOfDemo {
        public static void demo() {
            //test1();
            test2();
        }

        public static void test2() {

            unsafe {
                int x = sizeof(Student2);
                Console.WriteLine("struct Student2: " + x);
            }
        }

        public static void test1() {
            int x = sizeof(byte);
            Console.WriteLine("byte: " + x);
            x = sizeof(sbyte);
            Console.WriteLine("sbyte: " + x);
            x = sizeof(short);
            Console.WriteLine("short: " + x);
            x = sizeof(ushort);
            Console.WriteLine("ushort: " + x);
            x = sizeof(int);
            Console.WriteLine("int: " + x);
            x = sizeof(uint);
            Console.WriteLine("uint: " + x);
            x = sizeof(long);
            Console.WriteLine("long: " + x);
            x = sizeof(ulong);
            Console.WriteLine("ulong: " + x);
            x = sizeof(float);
            Console.WriteLine("float: " + x);
            x = sizeof(double);
            Console.WriteLine("double: " + x);
            x = sizeof(decimal);
            Console.WriteLine("decimal: " + x);
        }
    }

    struct Student2 {
        int ID;
        long Score;
    }
}
